# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo04
# Description:
# Author:       98745
# Date:         2019/3/10
#-------------------------------------------------------------------------------

import json
data={'name':'bill','company':'baidu','age':'21'}
js=json.dumps(data)
print(type(js))
print(js)
d=json.loads(js)
print(type(d))
print(d)

s='''{
'name':'pan',
'company':'ali',
'age':21
}'''
d1=eval(s)
print(type(d1))
print(d1)
print(d1['company'])

f=open('files/products.json','r',encoding='utf-8')
s1=f.read()
j1=eval(s1)
j2=json.loads(s1)
print(j1)
print(j2)
print(j2[0]['name'])
f.close()